<html>
  <head>
    <title>交易系统－－订单查询</title>
    <style type="text/css">
      <!--

      .style001 {
        font-size: 9px;
      }

      .STYLE4 {
        color: #7C99E2
      }

      .STYLE14 {
        color: #ddffff
      }

      .submitall {
        height: 22px;
        line-height: 22px;
      }
      -->
    </style>
  </head>
  <body>
    <div id="queryOrderGrid" class="x-form-item">
    </div>
    <script>
        var orderds;
        Ext.onReady(function(){
            // second tabs built from JS
            tabs.getItem(0).setTitle('我的订单');
            //############## 订单Grid ##############
            var ordercm = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), {
                    header: '编号',
                    dataIndex: 'id'
                }, {
                    header: '定单号',
                    dataIndex: 'order_no',
                    width: 120
                }, {
                    header: '乘机日期',
                    dataIndex: 'fly_date',
                    sortable: true,
                    width: 80,
                    renderer: Ext.util.Format.dateRenderer('Y-m-d')
                }, {
                    header: '起飞时间',
                    dataIndex: 'fly_time',
                    width: 60
                }, {
                    header: '总金额',
                    dataIndex: 'price_sum',
                    sortable: true,
                    width: 50
                }, {
                    header: '订单状态',
                    dataIndex: 'status',
                    width: 70
                }, {
                    header: '支付状态',
                    dataIndex: 'trx_status',
                    width: 70
                }, {
                    header: '交易ID',
                    dataIndex: 'trx_id',
                    width: 120
                },{
                    header: '预定时间',
                    dataIndex: 'created_at',
                    width: 110,
                    renderer: Ext.util.Format.dateRenderer('Y-m-d H:i')
                },{
                    header: '操作',
                    width: 110,
                    renderer: operationRender
                }]);
            function operationRender(value, cellmeta, record, rowIndex, columnIndex, store){
                if (record.get("trx_status")=="等待支付"){
                    return "<a href=\"/ticket/personReadyPay?person_order_id="+record.get("order_no")+"\" target=_blank>马上支付</a>";
                }
            }
            //隐藏order数据库id
            ordercm.setHidden(1, !ordercm.isHidden(1));
            orderds = new Ext.data.Store({
                proxy: new Ext.data.HttpProxy({
                    url: '/ticket/getPersonWebOrders'
                }),
                reader: new Ext.data.JsonReader({
                    totalProperty: 'totalProperty',
                    root: 'root'
                }, [{
                        name: 'id'
                    }, {
                        name: 'price_sum'
                    }, {
                        name: 'order_no'
                    }, {
                        name: 'pnr'
                    }, {
                        name: 'trx_status'
                    }, {
                        name: 'trx_id'
                    }, {
                        name: 'status'
                    }, {
                        name: 'from'
                    }, {
                        name: 'to'
                    }, {
                        name: 'fly_date'
                    }, {
                        name: 'fly_time'
                    }, {
                        name: 'created_at'
                    }])
            });

            var ordergridpanel = new Ext.grid.GridPanel({
                el: 'queryOrderGrid',
                ds: orderds,
                cm: ordercm,
                //sm: sm,
                loadMask: true,
                autoWidth: true,
                collapsible: true,
                animCollapse: true,
                height: 380,
                title: '订单信息',
                bbar: new Ext.PagingToolbar({
                    pageSize: 10,
                    store: orderds,
                    displayInfo: true,
                    displayMsg: '显示第 {0} 条到 {1} 条记录，一共 {2} 条',
                    emptyMsg: "没有记录"
                })

            });

            ordergridpanel.render();
            //ds.load();
            orderds.load({
                params: {
                    start: 0,
                    limit: 10
                }
            });
        });
        function gotoPay(webOrderID){
            Ext.Ajax.request({
                url: '/ticket/personReadyPay?web_order_id='+webOrderID,
                method: 'GET',
                success: function(result, request){
                    if (result.responseText == "SUCCESS") {
                        Ext.MessageBox.alert('消息', '特价信息保存成功!');
                    }
                    else {
                        Ext.MessageBox.alert('消息', result.responseText);
                    }
                },
                failure: function(result, request){
                    Ext.MessageBox.alert('消息', '特价信息保存!');
                }
            });
        }
    </script>
  </body>
</html>
